package com.zuowei.ycy.user.adapter;

import android.content.Context;
import android.view.View;
import android.widget.RatingBar;

import com.and.yzy.frame.adapter.CommonAdapter;
import com.and.yzy.frame.adapter.ViewHolder;
import com.and.yzy.frame.base.BaseFrameAty;
import com.zuowei.ycy.R;
import com.zuowei.ycy.user.domain.GoodInfo;

import java.util.List;

/**
 * Created by Administrator on 2016/4/25.
 */
public class GoodInfoAdapter extends CommonAdapter<GoodInfo> {
    public GoodInfoAdapter(Context context, List<GoodInfo> mList, int itemLayoutId) {
        super(context, mList, itemLayoutId);
    }

    @Override
    public void convert(ViewHolder holder, GoodInfo item, int positon) {

        switch (item.getStatus()) {
            case "0":
                holder.setViewVisibility(R.id.v_bg, View.VISIBLE)
                        .setTextViewText(R.id.tv_type, "休息中")
                      .setOnClick(R.id.v_bg, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {

                                ((BaseFrameAty) mContext).showToast("暂未营业");
                            }
                        })
                ;

                break;
            case "1":


                holder.setViewVisibility(R.id.v_bg, View.GONE)
                        .setTextViewText(R.id.tv_type, "营业中")
                ;
                break;

        }


        holder.setImageByUrl(R.id.iv_good,item.getHead_pic())
                .setTextViewText(R.id.tv_name,item.getShop_name())
                .setTextViewText(R.id.tv_price,"￥"+item.getLowest_price())
                .setTextViewText(R.id.tv_take_price,"￥"+item.getDelivery_fee())
                .setTextViewText(R.id.tv_time,item.getComment_del_time()+"分钟")
                .setTextViewText(R.id.tv_select_num,item.getSales()+"总销量");
        RatingBar ratingBar=holder.getView(R.id.rb_pinlun);

        ratingBar.setRating(Float.parseFloat(item.getComment_score()));










    }
}
